package main

import (
	"GORM_Demo04/part07/TestStruct"

	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
)

/**
一对多的关系
外键放在多的那边
在少的那边进行指定外键存储和外键的关系
	//ForeignKey:DLID数据存在外表中
	//AssociationForeignKey:LID关联的是本表的字段
	As []Department `gorm:"ForeignKey:DLID;AssociationForeignKey:LID"`

*/

func main() {
	db, err := gorm.Open("mysql", "root:123456@tcp(192.168.11.189:3306)/lztest?charset=utf8&parseTime=True&loc=Local")

	if err != nil {
		panic(err)
	}
	defer db.Close()

	db.CreateTable(&TestStruct.Department{})
	db.CreateTable(&TestStruct.Leader{})
}
